#include "ythtlib.h"
static const int numtable[255] = {
	1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
	11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
	21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
	31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
	41, 42, 43, 44, 45, 46, 47, 48, 49, 50,
	51, 52, 53, 55, 56, 57, 59, 61, 63, 65,
	67, 69, 71, 74, 77, 80, 83, 86, 90, 94,
	98, 103, 108, 113, 118, 124, 131, 138, 145, 153,
	161, 170, 180, 190, 201, 213, 226, 240, 255, 270,
	287, 305, 324, 345, 367, 391, 417, 444, 473, 505,
	538, 574, 613, 654, 699, 746, 797, 852, 910, 973,
	1040, 1112, 1189, 1272, 1360, 1455, 1557, 1666, 1782, 1907,
	2041, 2185, 2339, 2504, 2681, 2870, 3073, 3290, 3524, 3773,
	4041, 4328, 4635, 4964, 5317, 5695, 6101, 6535, 7000, 7499,
	8033, 8606, 9219, 9877, 10581, 11336, 12145, 13012, 13941, 14937,
	16004, 17147, 18372, 19685, 21092,
	22599, 24214, 25945, 27800, 29788,
	31918, 34201, 36646, 39267, 42076,
	45086, 48311, 51767, 55471, 59439,
	63692, 68249, 73133, 78366, 83973,
	89983, 96422, 103322, 110717, 118640,
	127131, 136230, 145980, 156429, 167625,
	179623, 192479, 206256, 221020, 236840,
	253793, 271960, 291427, 312288, 334642,
	358596, 384266, 411773, 441249, 472836,
	506684, 542955, 581822, 623472, 668104,
	715931, 767183, 822103, 880955, 944020,
	1011600, 1084018, 1161620, 1244778, 1333889,
	1429380, 1531707, 1641359, 1758862, 1884776,
	2019705, 2164294, 2319233, 2485265, 2663182,
	2853837, 3058141, 3277071, 3511675, 3763073,
	4032469, 4321152, 4630501, 4961996, 5317223,
	5697881, 6105791, 6542902, 7011306, 7513244,
	8051115, 8627493, 9245133, 9906990, 10616230,
	11376244, 12190668, 13063396, 13998603, 15000762,
	16074665, 17225449, 18458618, 19780069, 21196124
};

unsigned char
numbyte(int n)
{
	int i;
	if (n <= 0)
		return 0;
	for (i = 0; i < 254; i++)
		if (n <= numtable[i])
			break;
	return i + 1;
}

int
bytenum(unsigned char c)
{
	if (!c)
		return 0;
	return numtable[c - 1];
}
